﻿<phoneNavigation:PhoneApplicationPage 
    x:Class="OneBusAway.WP7.View.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phoneNavigation="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:pivot="clr-namespace:Phone.Controls.Samples;assembly=Phone.Controls.Samples"    
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"   
    xmlns:data="clr-namespace:OneBusAway.WP7.ViewModel;assembly=OneBusAway.WP7.ViewModel" 
    xmlns:view="clr-namespace:OneBusAway.WP7.View;assembly=OneBusAway.WP7.View"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}">

    <phoneNavigation:PhoneApplicationPage.Resources>
        <data:MainPageVM x:Key="ViewModel" />
        
        <!--<viewModel:RouteDirectionsMV x:Key="RouteStopsList" />-->

        <view:StopRoutesConverter x:Key="StopRoutesConverter"></view:StopRoutesConverter>
        <view:DistanceConverter x:Key="DistanceConverter"></view:DistanceConverter>
        
        <!-- TextBox styles -->
        <Style x:Key="PhoneTextPageTitle1Style" TargetType="TextBlock" BasedOn="{StaticResource PhoneTextNormalStyle}">
            <Setter Property="Margin" Value="20,20,0,0" />
        </Style>

        <Style x:Key="PhoneTextPageTitle2Style" TargetType="TextBlock" BasedOn="{StaticResource PhoneTextTitle1Style}">
            <Setter Property="Margin" Value="20,43,0,0" />
        </Style>

        <DataTemplate x:Key="StopTemplate">
            <StackPanel Orientation="Horizontal">
                <Canvas Width="44" Height="62" Margin="3" >
                    <Polygon Grid.Row="1" Points="0,0 32,0 32,32 0,61" Fill="{StaticResource PhoneForegroundBrush}" Opacity="1.0"/>
                    <TextBlock Text="{Binding stopIndex}" Margin="5" Foreground="{StaticResource PhoneBackgroundBrush}" />
                </Canvas>
                <StackPanel Orientation="Vertical">
                    <TextBlock Text="{Binding name}" />
                    <TextBlock Foreground="{StaticResource PhoneSubtleBrush}" FontSize="{StaticResource PhoneFontSizeSmall}" Text="{Binding Converter={StaticResource DistanceConverter}}" />
                    <TextBlock Foreground="{StaticResource PhoneSubtleBrush}" FontSize="{StaticResource PhoneFontSizeSmall}" Text="{Binding Converter={StaticResource StopRoutesConverter}}" />
                </StackPanel>
            </StackPanel>
        </DataTemplate>

        <DataTemplate x:Key="RouteTemplate">
            <StackPanel Orientation="Horizontal">
                <Canvas Width="44" Height="62" Margin="3" >
                    <Polygon Grid.Row="1" Points="0,0 32,0 32,32 0,61" Fill="{StaticResource PhoneForegroundBrush}" Opacity="1.0"/>
                    <TextBlock Text="{Binding shortName}" Margin="5" Foreground="{StaticResource PhoneBackgroundBrush}" />
                </Canvas>
                <StackPanel Orientation="Vertical">
                    <TextBlock Text="{Binding description}" />
                    <!--<TextBlock Foreground="{StaticResource PhoneSubtleBrush}" FontSize="{StaticResource PhoneFontSizeSmall}" Text="{Binding description}" />-->
                    <TextBlock Foreground="{StaticResource PhoneSubtleBrush}" FontSize="{StaticResource PhoneFontSizeSmall}" Text="{Binding Converter={StaticResource DistanceConverter}}" />
                </StackPanel>
            </StackPanel>
        </DataTemplate>

        <DataTemplate x:Key="RouteStopsTemplate">
            <StackPanel Orientation="Horizontal" Height="150">
                <Canvas Width="64" Height="140" Margin="3" >
                    <Polygon Grid.Row="1" Points="0,0 48,0 48,64 0,120" Fill="{StaticResource PhoneForegroundBrush}" Opacity="1.0"/>
                    <TextBlock Text="{Binding route.shortName}" Margin="5" Foreground="{StaticResource PhoneBackgroundBrush}" />
                </Canvas>
                <StackPanel Orientation="Vertical">
                    <StackPanel Orientation="Horizontal">
                        <StackPanel Orientation="Vertical" Width="300">
                            <TextBlock Text="Redmond" />
                            <TextBlock Foreground="{StaticResource PhoneSubtleBrush}" FontSize="{StaticResource PhoneFontSizeSmall}" Text="Stone Way N &amp; N 43rd St (0.06 mi)" />
                        </StackPanel>
                        <TextBlock>
                            <Run FontWeight="Bold" FontSize="50" Text="3" />
                            <Run FontSize="18" Text="min" />
                        </TextBlock>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <StackPanel Orientation="Vertical" Width="300">
                            <TextBlock Text="Seattle" />
                            <TextBlock Foreground="{StaticResource PhoneSubtleBrush}" FontSize="{StaticResource PhoneFontSizeSmall}" Text="N 45th St &amp; Stone Way N (0.12 mi)" />
                        </StackPanel>
                        <TextBlock>
                            <Run FontWeight="Bold" FontSize="50" Text="12" />
                            <Run FontSize="18" Text="min" />
                        </TextBlock>
                    </StackPanel>
                </StackPanel>
            </StackPanel>

        </DataTemplate>
    </phoneNavigation:PhoneApplicationPage.Resources>

    <Grid x:Name="LayoutRoot" Background="{StaticResource PhoneBackgroundBrush}">
        <pivot:PivotControl Name="PC">
            <pivot:PivotItem Title="ONE BUS AWAY" Header="routes">
                <ListBox x:Name="RoutesListBox" ItemsSource="{Binding Path=RoutesForLocation, Source={StaticResource ViewModel}}" ItemTemplate="{StaticResource RouteTemplate}" />
            </pivot:PivotItem>
            <pivot:PivotItem Title="ONE BUS AWAY" Header="stops">
                <ListBox x:Name="StopsListBox" ItemsSource="{Binding Path=StopsForLocation, Source={StaticResource ViewModel}}" ItemTemplate="{StaticResource StopTemplate}" />
            </pivot:PivotItem>
        </pivot:PivotControl>
    </Grid>

</phoneNavigation:PhoneApplicationPage>
